<template>
  <bar-chart id="instCatStats" :config="barConfig" />
</template>

<script>
import BarChart from '@neu/biz-core/components/Charts/BarChart'
import { statsByCategory as instanceStatsByCategory } from '@neu/cmdb-ui/api/instance'
export default {
  name: 'InstCatStats',
  components: {
    BarChart
  },
  data() {
    return {
      barConfig: {
        type: 'bar',
        title: '实例分类统计',
        dataSource: []
      }
    }
  },
  created() {
    instanceStatsByCategory().then(response => {
      this.barConfig.dataSource = response.data.map(it => [it.name, it.count])
    })
  }
}
</script>
